<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      class Calculator {
        /**
         * @param {number} value
         */
        constructor(value) {
          this.result = value;
        }

        /**
         * @param {number} value
         * @return {Calculator}
         */
        add(value) {
          this.result += value;
          return this;
        }

        /**
         * @param {number} value
         * @return {Calculator}
         */
        subtract(value) {
          this.result -= value;
          return this;
        }

        /**
         * @param {number} value
         * @return {Calculator}
         */
        multiply(value) {
          this.result *= value;
          return this;
        }

        /**
         * @param {number} value
         * @return {Calculator}
         */
        divide(value) {
          if (value === 0) throw "Division by zero is not allowed";
          this.result /= value;
          return this;
        }

        /**
         * @param {number} value
         * @return {Calculator}
         */
        power(value) {
          this.result **= value;
          return this;
        }

        /**
         * @return {number}
         */
        getResult() {
          return this.result;
        }
      }
    </script>
  </body>
</html>
